package com.situ.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.situ.service.SyMetertypeService;
import com.situ.entity.SyMetertype;

import java.util.*;

/**
 * SyMetertype的路由接口服务
 *
 * @author 胡文
 */
@Controller
public class SyMetertypeController {

    /**
     * SyMetertypeService服务
     */
    @Autowired
    private SyMetertypeService syMetertypeService;

    @RequestMapping("/sys_meterType_add")
    public String s() {
        return "sys_meterType_add.html";
    }

    /**
     * 查询所有SyMetertype数据的方法
     *
     * @param value
     * @return
     */
    @RequestMapping(value = "querySyMetertype", produces = {"application/json;charset=UTF-8"})
    public String find(SyMetertype value, Map map) {
        List<SyMetertype> list = syMetertypeService.find(value);
        map.put("list", list);
        return "sys_meterType.html";
    }

    /**
     * 通过id查询SyMetertype数据的方法
     *
     * @return
     */
    @RequestMapping(value = "querySyMetertypeById/{id}", produces = {"application/json;charset=UTF-8"})
    public String findOne(@PathVariable(name = "id") Object id, Map map) {
        SyMetertype obj = syMetertypeService.findOne(id);
        map.put("SyMetertype", obj);
        return "sys_meterType_add.html";
    }

    /**
     * 插入SyMetertype属性不为空的数据方法
     *
     * @return
     */
    @RequestMapping(value = "saveSyMetertype", produces = {"application/json;charset=UTF-8"})
    public String save(SyMetertype value) {
        syMetertypeService.saveNotNull(value);
        return "redirect:/querySyMetertype";
    }

    /**
     * 更新SyMetertype属性不为空的数据方法
     *
     * @return
     */
    @RequestMapping(value = "updateSyMetertype", produces = {"application/json;charset=UTF-8"})
    public String update(SyMetertype value) {
        syMetertypeService.updateNotNullById(value);
        return "redirect:/querySyMetertype";
    }

    /**
     * 通过id删除SyMetertype数据方法
     *
     * @return
     */
    @RequestMapping(value = "delSyMetertypeById/{id}", produces = {"application/json;charset=UTF-8"})
    public String delete(@PathVariable(name = "id") Object id) {
        syMetertypeService.deleteById(id);
        return "redirect:/querySyMetertype";
    }
}
